package xiaoming;

import java.math.BigDecimal;
import java.util.Scanner;

public class java_chapter5_shangji_2_3 {

	public static void main(String[] args) {
		System.out.println("my shopping 管理系统>购物结算");
		String reply;
		String name = "";
		double price = 0.0;
		int amount;
		double heji;
		double discount = 0.8;
		Scanner in = new Scanner(System.in);
		double shouldPay = 0.0;
		BigDecimal bd = new BigDecimal(shouldPay);
		shouldPay = bd.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
		do {
			System.out.println("请选择购买的商品编号：" + "1.T恤\t2.网球鞋\t3.网球拍");
			System.out.print("请输入商品编号：");
			int goodsNo = in.nextInt();
			System.out.print("请输入购买数量：");
			amount = in.nextInt();
			switch (goodsNo) {
			case 1:
				name = "T恤";
				price = 245.0;
				break;
			case 2:
				name = "网球鞋";
				price = 570.0;
				break;
			case 3:
				name = "网球拍";
				price = 320.0;
			default:
				break;
			}
			heji = price * amount;
			shouldPay += heji;
			System.out.println(name + "￥" + price + "\t数量:" + amount + "\t合计" + heji + "\n");
			System.out.println("是否继续（y/n):");
			reply = in.next();
		} while ("y".equals(reply));
		
		System.out.println("discount:" + 0.8);
		System.out.println("应付金额：" + shouldPay * 0.8);
		System.out.print("实付金额：");
		double actuallyPay = in.nextDouble();
		System.out.println("找钱：" + (actuallyPay - (shouldPay) * 0.8));
		
	}
	
}





